package batch;

import getBaiduPaid.Config;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class QueryGenerator {
	static String ENC = "utf-8";
	
	public String genQueryUrl (String keyword) throws UnsupportedEncodingException{
		String url = Config.Query.concat(URLEncoder.encode(keyword,ENC));
		return url;
	}
	
	public String[] genQueryUrlArray (String filename) throws IOException {
		FileArrayProvider fap = new FileArrayProvider();
		String[] lines = fap.readLines(filename);
		String[] linesENC = new String[lines.length];
		
		int n = 0;
		for (String s : lines) {
			linesENC[n] = genQueryUrl(s);
			n++;
		}
		return linesENC;
	}
}
